package com.wx.controller;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 原始的实现 Controller 接口的写法
 */
public class SimpleController implements Controller {

	@Override
	public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {

		ModelAndView mv = new ModelAndView();
		// TODO: 配置了 InternalResourceViewResolver 就不需要写全了
		mv.setViewName("simple");
//		mv.setViewName("/WEB-INF/page/simple.jsp");
		mv.addObject("name", "角落处的一抹微光~~");

		return mv;
	}
}

/**
 * 类似于原始的 Servlet 的写法
 */
//public class SimpleController implements HttpRequestHandler {
//
//	@Override
//	public void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//		request.setAttribute("name", "角落处的一抹微光~~~");
//		request.getRequestDispatcher("/WEB-INF/page/simple.jsp").forward(request, response);
//	}
//}